
#pragma once

using namespace System::Collections::Generic;
using namespace System::Reflection;

#include "IUtility.h"

namespace ttg_internal
{
	namespace utils
	{
		///<summary>
		/// Searches for utilities and loads them.
		///</summary>
		private ref class UtilLoader abstract sealed
		{
			internal:
				///<summary>
				/// Sets resolver for UtilManager assembly.
				///</summary>
				static UtilLoader();
				///<summary>
				/// Returns collections with directories, that may contain utilities.
				/// Currently, it is current directory and $(TTGLIB_HOME)/Bin/Utils.
				///</summary>
				static IEnumerable<System::String ^> ^GetUtilityDirs();
				///<summary>
				/// Returns collections with potential pathes for UtilManager.dll.
				///</summary>
				static IEnumerable<System::String ^> ^GetUtilManagerPathes();
				///<summary>
				/// Tries to load UtilManager.dll from $(TTGLIB_HOME/bin).
				///</summary>
				static Assembly^ MyResolveEventHandler(System::Object^ sender, System::ResolveEventArgs^ args);
				///<summary>
				/// Tries to load utility with given name from assemblies (located at "Path" directory).
				/// In case of fail, returns nullptr and stores error description.
				///<summary>
				static IUtility ^LoadUtility(System::String ^name,
											 System::String ^&error);
				///<summary>
				/// Tries to load the first utility from required assembly.
				/// In case of fail, returns nullptr and stores error description.
				///<summary>
				static IUtility ^LoadUtilityFromFile(System::String ^filename,
													 System::String ^&error);
				///<summary>
				/// Tries to find all available utilities. Returns their names.
				///</summary>
				static List<System::String ^> ^findAvailableUtilities();
		};
	}
}
